<script type="text/javascript">
function setDropDown(id, count)
{
	var menu = jQuery('#'+id);
	var pos = jQuery('#'+id).position();
	
	//alert(count);
	//alert('left '+pos.left+' right '+pos.top);
	var myHeight = jQuery('#'+id).height();
	var _top = pos.top + myHeight;
	var _left = pos.left;
	
	if(count == 4)
	{
		_left = _left - 340;
	}
	
	if(count == 5)
	{
		_left = _left - 200;
	}
	
	if(count == 7)
	{
		_left = _left - 558;
	}
	
	jQuery('.menu-container').css({'top':(_top),'left':_left});
}
</script>

<?php
//getting top level categories
global $topMenuCats;
 $args = array(
	'type'                     => 'post',
	'child_of'                 => 0,
	'parent'                   => '',
	'hide_empty'               => 0,
	'hierarchical'             => 1,
	'include'                  => '117,113,28,160,60,168,179,186',
	'taxonomy'                 => 'category');
	
$topMenuCats = get_categories($args);

/*echo '<pre>';
print_r($topMenuCats);
echo '</pre>';*/
?>
<ul class="top-menu">
<?php 
$menu_count = '';
foreach($topMenuCats as $tc):?>
  <li><a href="#" id="menu-item-<?php echo $tc -> cat_ID?>" onmouseover="setDropDown(this.id, <?php echo ++$menu_count?>)"><?php echo $tc -> name?></a>
  <?php
  //getting its child
  $args = array(
	'type'                     => 'post',
	'parent'                   => $tc -> cat_ID,
	'hide_empty'               => 0,
	'taxonomy'                 => 'category');
	
	$subMenuCats = get_categories($args);
	/*echo '<pre>';
print_r($subMenuCats);
echo '</pre>';*/
  ?>
  	<div class="menu-container">
    <?php foreach($subMenuCats as $sc):?>
    	<ul>
        	<li class="heading"><a href="<?php echo get_category_link($sc -> cat_ID)?>"><?php echo $sc -> name?></a></li>
            
            <?php
            //getting last child
				$args = array(
				'type'                     => 'post',
				'parent'                   => $sc -> cat_ID,
				'hide_empty'               => 0,
				'taxonomy'                 => 'category');
				
				$ssMenuCats = get_categories($args);
				
				//check if any sub cats exist otherwise make a same name sub cate
				if(count($ssMenuCats) == 0)
				{
					echo '<li><a href="#">'.$sc -> name.'</a></li>';
				}
				else
				{
					foreach($ssMenuCats as $ssc):
			?>
    				<li><a href="<?php echo get_category_link($ssc -> cat_ID)?>"><?php echo $ssc -> name?></a></li>
            <?php 	
					endforeach;
				}
			?>
    	</ul>
     <?php endforeach;?>

        <div style="width: 100%; clear: both;"></div>
    </div>
   	
  </li>
  
<?php endforeach;?>
</ul>